﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using mesoBoard.Data.Repositories;
using System.Web.Security;
using mesoBoard.Data;

namespace mesoBoard.Web.Providers
{
    public class UserRoles : RoleProvider
    {
        UserRepository UserRep;

        public UserRoles()
        {
            
        }

        public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
        {
            if(System.Configuration.ConfigurationManager.AppSettings["Installed"] != "false")
                this.UserRep = new UserRepository(new mbEntities());
            base.Initialize(name, config);
        }
        public override string[] GetRolesForUser(string username)
        {
            return UserRep.GetUserRoles(username);
        }

        public override bool IsUserInRole(string username, string roleName)
        {
            return UserRep.GetUserRoles(username).ToList().Exists(x => x == roleName);
        }

        public override void AddUsersToRoles(string[] usernames, string[] roleNames)
        {
            throw new NotImplementedException();
        }

        public override string ApplicationName
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public override void CreateRole(string roleName)
        {
            throw new NotImplementedException();
        }

        public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)
        {
            throw new NotImplementedException();
        }

        public override string[] FindUsersInRole(string roleName, string usernameToMatch)
        {
            throw new NotImplementedException();
        }

        public override string[] GetAllRoles()
        {
            throw new NotImplementedException();
        }

        public override string[] GetUsersInRole(string roleName)
        {
            throw new NotImplementedException();
        }
        public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames)
        {
            throw new NotImplementedException();
        }

        public override bool RoleExists(string roleName)
        {
            throw new NotImplementedException();
        }
    }

}
